/**
 * The route object contains textual and geographical information
 * about every step on a route between two locations.
 * 
 * @author Kim Pommert
 * @version %I%, %G%
 */
qx.Class.define("qooxdoosample.cocktail.util.Route",
{
	extend: qx.core.Object,
	
	/**
	 * Class constructor.
	 * Instantiates an object of that class.
	 * 
	 * @param line	{qooxdoosample.cocktail.util.overlays.Polyline} 
	 * 						An overlay that follows every step of the route
	 */
	construct: function(line)
	{
		this.setPolyline(line);
	},
	
	properties :
	{
		/**
		 * The overlay that represents the whole route.
		 */
    	polyline:
    	{
      		nullable: true,
      		init: null,
      		check: "qooxdoosample.cocktail.util.overlays.Polyline"
      	},
      	
      	/**
      	 * An array that contains all steps of the route.
      	 */
      	steps:
      	{
      		nullable: true,
      		init: null,
      		check: "Array"
      	},
      	
      	/**
      	 * The distance of the whole route.
      	 * The default unit of the distance is meters.
      	 */
      	distance:
      	{
      		nullable: true,
      		init: null,
      		check: "Number"
      	},
      	
      	/**
      	 * The duration of the whole route.
      	 * The default unit of the duration is seconds.
      	 */
      	duration:
      	{
      		nullable: true,
      		init: null,
      		check: "Number"
      	}
	},

	members:
	{
		
		/**
		 * Get the number of steps in this route.
		 * 
		 * @return	{Integer} The number of steps
		 */
		getNumSteps: function()
		{
			var steps = this.getSteps();
			return steps.length;
		},
		
		/**
		 * Get a specific step in the route.
		 * The first step has the index 0
		 * 
		 * @param index	{Integer} The steps index
		 * @return	{qooxdoosample.cocktail.util.Step} The step
		 */
		getStep: function(index)
		{
			var steps = this.getSteps();
			return steps[index];
		},
		
		/**
		 * Get the geographic coordinates of the start point of that route.
		 * 
		 * @return	{qooxdoosample.cocktail.util.LatLng} The coordinates of the start point
		 */
		getStartLatLng: function()
		{
			return this.getPolyline().getStartPoint();
		},
		
		/**
		 * Get the geographic coordinates of the end point of that route.
		 * 
		 * @return	{qooxdoosample.cocktail.util.LatLng} The coordinates of the end point
		 */
		getEndLatLng: function()
		{
			return this.getPolyline().getEndPoint();
		}
	}
});